package DB;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;

import Entities.GameCharacter;

public class DBCharacterConnector extends DBConnector{
	static public LinkedList<GameCharacter> getCharacterList(int offset,int speciesID){
		LinkedList<GameCharacter> CharacterList=new LinkedList<GameCharacter>();
		String sql="{call getCharacterFromSpecies(?)}";	
		CallableStatement cs1;
		Connection conn=openConnection();
		try {
			 cs1 = conn.prepareCall(sql);
			 cs1.setInt(1, speciesID);
			 ResultSet rs=cs1.executeQuery();
			 while (rs.next()){
				 GameCharacter temp=new GameCharacter(rs.getString("name"),rs.getString("freeBaseID"),rs.getInt("id"));
				 CharacterList.add(temp);
			 }
		     cs1.close();
		     closeConnection(conn);
		}
	     catch (SQLException e) {}
		return CharacterList;
	} 
}
